#include "cBullet.h"

cBullet::cBullet( IrrlichtDevice* device, vector2d<s32> startPos, vector2d<s32> moveVector ) : 
	_vMoveVector(moveVector)
{
	_pBulletTexture = device->getVideoDriver()->getTexture("../resources/character_basic_green.png");
	device->getVideoDriver()->makeColorKeyTexture( _pBulletTexture, core::position2d<s32>(1,1) );

	_pNode = device->getSceneManager()->addCubeSceneNode();
	_pNode->setMaterialFlag(video::EMF_LIGHTING, false);
	_pNode->setPosition( vector3df( startPos.X, startPos.Y, 20 ) );
	_pNode->setMaterialTexture(0, _pBulletTexture);
	std::cout << "Spawning bullet.\n";
}

void cBullet::Update()
{
	_pNode->setPosition( vector3df( 
		_pNode->getPosition().X + _vMoveVector.X, 
		_pNode->getPosition().Y + _vMoveVector.Y,
		_pNode->getPosition().Z ) );
}

vector3df cBullet::GetPosition()
{
	return _pNode->getPosition();
}